<extend name="Public/base"/>

<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>


<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<!-- <div id="main-content" style="">
<div class="main" id="main" style="">  -->
  
  <!-- nav --> 
  
  <!-- nav --> 
  
  <!-- 数据列表 -->
  
  <div class="data-table" style="">
    <div class="data-table table-striped" style="">
      <div class="picmsg" style="">
        <div class="yz_left">
          <div id="portamento_container" style="min-height: 145px; width: 311px;"><div id="sidebar" style="top: 0px;">
            
          </div>
        </div>
          
          
          
          <div  class="tjgg">
          

<div class="form_itme">
           <div>
              <strong class="title yz_left">规格名称: </strong>
          <input type="text" value="" id="rulename" name="phone" >
          </div><div>
          <strong class="title yz_left">规格价格: </strong>
          <input type="text" value="" id="ruleprice" name="phone" >
          </div>
          <div>
          <strong class="title yz_left">剩余库存: </strong>
          <input type="text" value="" id="goodstock" name="phone" >
          <button class='bcs'>添加规格</button>
          <button class='ttjson'>表格转json</button>
          </div>         
            </div>
              

<div id="ruletable">
  <table id="ruletable" border="1" cellpadding="5" cellspacing=0>
				<tbody>
					<tr>
						<th>规格名称</th>
						<th>规格价格</th>
						<th>剩余库存</th>
						<th>&nbsp;</th>
					</tr>
					
					 <volist name="rulelist" id="ruledata">
					 	<tr>
											<td>{$ruledata.rule_name}</td>
											<td>{$ruledata.rule_price}</td>
											<td>{$ruledata.stock}</td>
<!--
											<td><a class="ruledel" href="{:U(goodsruledel)}">鍒犻櫎</a></td>
-->
											<td><a class="ruledel">删除</a></td>
											<input type="hidden" name="ruleid" value="{$ruledata.id}" id="ruleid{$ruledata.id}"/>
						</tr>
					 </volist>
					<!--
					<tr>
											<td>Tom</td>
											<td>tom@tom.com</td>
											<td>5000</td>
											<td><a href="deleteEmp?id=Tom">鍒犻櫎瑙勬牸</a></td>
										</tr>
										<tr>
											<td>Jerry</td>
											<td>jerry@sohu.com</td>
											<td>8000</td>
											<td><a href="deleteEmp?id=Jerry">鍒犻櫎瑙勬牸</a></td>
										</tr>-->
					
				</tbody>
			</table>
</div>

</div>
        </div>
        
        
        
        <div class="yz_right width540 fromblock" style="">
        	<!--
			<?php
				  var_dump($shoplist);
					  ?>-->
			
          <form   enctype="multipart/form-data" action="{:U('insertone')}" class="form-horizontal" method="post" style="">
            <div class="form_itme">
              <label class="form_label yz_clear">
              <strong class="title yz_left">所属类别</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span style="display:block" class="counter_in yz_clear">
              <select id="cat_id" name="cat_id">
              	 <volist name="catlist" id="cat">
                  
                    <option value="{$cat['id']}"> 
                     {$cat['cat_name']}
                  </option>
                </volist>
                </select>
              </span> </div>
              
              
              
              <div class="form_itme">
              <label class="form_label yz_clear">
              <strong class="title yz_left">所属商家</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span style="display:block" class="counter_in yz_clear">
              <select id="shop_id" name="shop_id">
              	
              	<volist name="shoplist" id="shoplist">
                  
                    <option value="{$shoplist['id']}"> 
                     {$shoplist['shopname']}
                  </option>
                </volist>
                                     </select>
              </span> </div>
              
              <div id="parentIframe">aavbbdd</div>
              <?php 
              var_dump($rulelist);
              
               ?>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">标题</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="{$info.good_name|default=''}" name="good_name" id="good_name" class="form_input limited">
              <em class="form_input_append frm_counter">64/64</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">产品特点</strong>
              <p class="tips yz_left">（设置产品特点之后前台页面可以开始产品特点功能）</p>
              </label>
           <!--    <div class=" counter_in yz_clear"> 
              <div class="icheckbox_minimal checked" style="position: relative;">
              <input type="checkbox" checked="" value="" name="istop" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;">
              </ins></div> 热门 <div class="icheckbox_minimal checked" style="position: relative;"><input type="checkbox" checked="" value="" name="isrecommend" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div> 推荐 <div class="icheckbox_minimal checked" style="position: relative;"><input type="checkbox" checked="" value="" name="isspecial" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div> 特别推荐 
              </div> -->
              <div class=" counter_in yz_clear"> <input type="checkbox" name="istop" value="{$vo.istop}" 
                <eq name="vo.istop">checked</eq>
                > 热门 <input type="checkbox" name="isrecommend" value="{$vo.isrecommend}" 
                <eq name="vo.isrecommend">checked</eq>
                > 推荐 <input type="checkbox" name="isspecial" value="{$vo.isspecial}" 
                <eq name="vo.isspecial">checked</eq>
                > 特别推荐 </div>
            </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">产品标签</strong>
              <p class="tips yz_left">（设置产品标签之后前台页面可以开始产品标签功能）</p>
              </label>
              <!-- <div class=" counter_in yz_clear"> <div class="iradio_minimal" style="position: relative;"><input type="radio" value="0" name="label" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div> 不使用 <div class="iradio_minimal" style="position: relative;"><input type="radio" value="1" name="label" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div>
                
                今日特价 <div class="iradio_minimal" style="position: relative;"><input type="radio" value="2" name="label" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div>热销商品<div class="iradio_minimal" style="position: relative;"><input type="radio" value="3" name="label" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; background: rgb(255, 255, 255) none repeat scroll 0% 0%; border: 0px none; opacity: 0;"></ins></div>新品上架 
                </div> -->
                <div class=" counter_in yz_clear"> <input type="radio" name="label" value="0" 
                <eq name="vo.label" value="0">checked</eq>
                > 不使用 <input type="radio" name="label" value="1" 
                <eq name="vo.label" value="1">checked</eq>
                >
                
                今日特价 <input type="radio" name="label" value="2" 
                <eq name="vo.label" value="2">checked</eq>
                >热销商品<input type="radio" name="label" value="3" 
                <eq name="vo.label" value="3">checked</eq>
                >新品上架 </div>
            </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">特色描述</strong>
              <p class="tips yz_left">（选填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" name="good_remark" id="good_remark" class="form_input limited">
              <em class="form_input_append frm_counter">32/32</em> </span> </div>
              
               <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">是否可邮</strong>
              <p class="tips yz_left">（选填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" name="shorttitle" id="shorttitle" class="form_input limited">
              <em class="form_input_append frm_counter">32/32</em> </span> </div>
           <!--  <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">商家咨询电话</strong>
              <p class="tips yz_left">（填写咨询电话，前台可以通过打电话联系商家）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="phone" name="phone" class="form_input limited">
              <em class="form_input_append frm_counter">11/11</em> </span> </div>
              <div class="form_itme">

              <label class="form_label">

              <strong class="title yz_left">商家联系邮箱</strong>

              <p class="tips yz_left">（填写联系邮箱，订单会以邮件形式发送）</p>

              </label>

              <span class="form_input_box counter_in yz_clear">

              <input type="text" value="" id="email" name="email" class="form_input limited">

              <em class="form_input_append frm_counter">11/11</em> </span> </div> -->
           <!--  <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">商品单位</strong>
              <p class="tips yz_left">（必填，例如0.5斤表示0.5斤对应的价格）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="unity" name="unity" class="form_input limited">
              <em class="form_input_append frm_counter">8/8</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">采购价格</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="price0" name="price0" class="form_input limited">
              <em class="form_input_append frm_counter">8/8</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">本店价格</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="price" name="price" class="form_input limited">
              <em class="form_input_append frm_counter">8/8</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">市场价格</strong>
              <p class="tips yz_left">（选填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="price1" name="price1" class="form_input limited">
              <em class="form_input_append frm_counter">8/8</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">产地</strong>
              <p class="tips yz_left">（选填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" id="producer" name="producer" class="form_input limited">
              <em class="form_input_append frm_counter">24/24</em> </span> </div>
            <div class="form_itme">
              <label class="form_label">
              <strong class="title yz_left">相关产品</strong>
              <p class="tips yz_left">（<a onclick="selectRelate('relation_text','')" class="" href="javascript:void()">选择</a>）</p>
              </label>
              <ul style="width:100%; clear:both" id="relation_text" class="list-dot">
                              </ul>
            </div> -->
            <div class="form_itme islows               hide              ">
              <label class="form_label">
              <strong class="title yz_left">开始时间</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" name="starttime" id="starttime" class="form_input limited">
              </span> </div>
            <div class="form_itme islows                hide              ">
              <label class="form_label">
              <strong class="title yz_left">结束时间</strong>
              <p class="tips yz_left">（必填）</p>
              </label>
              <span class="form_input_box counter_in yz_clear">
              <input type="text" value="" name="endtime" id="endtime" class="form_input limited">
              </span> </div>
           
              
              
              
              <div class="controls">
									封面：
									<input type="file" id="upload_picture_test">
									<input type="hidden" name="cover_id" id="cover_id_name"/>
									
									
									<div class="yz_grid"> <strong id="showtitle"></strong>
              <div class="panel-footer clearfix"><span class="pull-right gray"></span> </div>
              <div class="imgholder">
              	<a id="backpic" class="bigpic" target="_blank" href="javascript:void()"></a>
                 </div>
              <div id="showinfo" class="info"></div>
            </div>
            
								</div>
								<script type="text/javascript">
								//上传图片
							    /* 初始化上传插件 */
								$("#upload_picture_test").uploadify({
							        "height"          : 30,
							        "swf"             : "__STATIC__/uploadify/uploadify.swf",
							        "fileObjName"     : "download",
							        "buttonText"      : "上传图片",
							        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
							        "width"           : 120,
							        'removeTimeout'	  : 1,
							        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
							        "onUploadSuccess" : uploadPicturetest,
							        'onFallback' : function() {
							            alert('未检测到兼容版本的Flash.');
							        }
							    });
								function uploadPicturetest(file, data){
							    	var data = $.parseJSON(data);
							    	var src = '';
							        if(data.status){
							        	src = data.url || '__ROOT__' + data.path
							        	$("#backpic").html('<img src="' + src + '" />')
							        	$("#cover_id_name").val(data.id);
							        	//alert("aaaa");<img src="./Uploads/Picture/2015-08-08/55c609ff73a8b.jpg" />
							        	/*
										$("#cover_id_{$field.name}").val(data.id);
																				src = data.url || '__ROOT__' + data.path
																				$("#cover_id_{$field.name}").parent().find('.upload-img-box').html(
																					'<div class="upload-pre-item"><img src="' + src + '"/></div>'
																				);*/
										
							        } else {
							        	updateAlert(data.info);
							        	setTimeout(function(){
							                $('#top-alert').find('button').click();
							                $(that).removeClass('disabled').prop('disabled',false);
							            },1500);
							        }
							    }
								</script>
              
            <div class="form_itme yz_clear">
              <label class="form_label">
              <strong class="title yz_left">介绍</strong>
              <p class="tips yz_left">（选填）</p>
              </label>
              <span class="form_textarea_box yz_clear">
<!--
              <textarea name="description" max-length="120" id="description" class="form_textarea js_desc js_counter"></textarea>
-->
               <input type="text" name="good_brief" value="" id="good_brief"/>
              <em class="form_input_append frm_counter">120/120</em> </span> </div>
            <div class="form_itme yz_clear" id="pic" style="">
              <label class="form_label yz_clear">
              <strong class="title yz_left">详细说明</strong>
              <p class="tips yz_left">（自动保存：2015-04-10 22:59:39）</p>
              </label>
                               <label class="textarea">
                                <textarea name="good_desc" id="good_desc"></textarea>
                                {:hook('adminArticleEdit')}
                                </label>
              </div>
            
            <input type="hidden" id="islowed" value="" name="islow">
            <input type="hidden" id="ruleall" value="" name="ruleall">
            <input type="hidden" value="" name="id">
            <div class="yz_form_action">
              <button  id="testsub"  type="submit" target-form="form-horizontal" class="yz_btn submit-btn ajax-post no-refresh">确 定</button>
              <button onclick="javascript:history.back(-1);return false;" class="btn btn_default">返 回</button>
            </div>
          </form>
        </div>
        <div class="yz_clear"></div>
      </div>
      <div class="yz_clear"></div>
    </div>
    <div class="yz_clear"></div>
  </div>
  <div class="yz_clear"></div>
</div>
<div class="yz_clear"></div>
<link href="/shop/Public/artDialog/css/ui-dialog.css" rel="stylesheet">
<script src="/shop/Public/artDialog/js/dialog.js"></script> 
<script src="/shop/Public/artDialog/js/dialog-plus.js"></script> 



<script type="text/javascript">
function checktable(){
			
			//var34="333";			    
			// return var34;
			 var len=$('#ruletable tr').length;
 
//var aaa=$("ruletable tr td").eq(1).text();
//var aaa=$("#ruletable tr:eq(1) td:eq(1)").text();
var zj="";
if(len>1){
	zj="[";
	for (var i=1; i < len; i++) {
	  var aaa=$("#ruletable tr").eq(i).find("td").eq(0).text();
	  var bbb=$("#ruletable tr").eq(i).find("td").eq(1).text();
	  var ccc=$("#ruletable tr").eq(i).find("td").eq(2).text();
	  //zj=zj+"\{"+"rulename:'"+aaa+"',ruleprice:'"+bbb+"',rulestoce:'"+ccc+"\'},";
	 zj=zj+'{"rulename":"'+aaa+'","ruleprice":"'+bbb+'","rulestock":"'+ccc+'"},';
	  
	};
	zj=zj.substring(0,zj.length-1)+"]";
			 
			 }
			 return zj;
				}			    

$(function(){
	$(".ruledel").click(function() {
		
		layer.open({
        type: 2,
        title: '修改规格',
        maxmin: true,
        shadeClose: true, //点击遮罩关闭层
        area : ['400px' , '260px'],
        content: ["{:U('ruleedit',array('rule_id'=>9))}",'no']
   
               })
               
		/*
		var b=window.confirm("浣犵‘瀹氳鍒犻櫎锛�"+$(this).parent().parent().children().eq(0).text());
							
							if(b){
								//alert("varaaid==");
								var rule_id=$(this).parent().parent().find('input').val();
								//alert(varaa);
								var rule_url=$(this).attr('href');
								alert(rule_url);
								var send_data={"rule_id":rule_id};
					var xmlHttpRequest=$.post(rule_url,send_data,function(data,ts){
					
						window.location.reload();
						// //$(this).parent().parent().remove();
						// var rule_url2=$(this).attr('href');
						// alert(rule_url2);
						// var aa=$(this).parent().parent().text();
						// alert(aa);
						//
						
					})
		
					
				//	$(this).parent().parent().remove();
								return false;
							}else{
								return false;
							}*/
		
		});

	
$("#testsub").click(function() {
	var abc=checktable();
	if(abc){
		$("#ruleall").attr("value",abc);

		
	}else{
		alert("请增加规格");
		return false;
	}
	
		return true;
});

	$('#sidebar').portamento({

     wrapper: $('.picmsg')  // set #wrapper as the bottom boundary

      });
      
      $(".ttjson").click(function() {
         
 var data = " [ {name:'6101',value:'北京市',age:'11'}, {name:'6102',value:'天津市',age:'11'}, {name:'6103',value:'上海市',age:'22'}]"; 
 //$('#ruletable tr').append($tr);
 var len=$('#ruletable tr').length;
 
//var aaa=$("ruletable tr td").eq(1).text();
//var aaa=$("#ruletable tr:eq(1) td:eq(1)").text();
if(len<2){
	alert("tjgg"); 
}else{
	
	
	var zj="[";
	for (var i=1; i < len; i++) {
	  var aaa=$("#ruletable tr").eq(i).find("td").eq(0).text();
	  var bbb=$("#ruletable tr").eq(i).find("td").eq(1).text();
	  var ccc=$("#ruletable tr").eq(i).find("td").eq(2).text();
	  zj=zj+"\ {"+"rulename:'"+aaa+"',ruleprice:'"+bbb+"',rulestoce:'"+ccc+"\'},";
	 
	  
	};
	zj=zj.substring(0,zj.length-1)+"]"
	alert(zj);
	
}




         });

$(".bcs").click(function(){
	
	// $(".tjgg").append($(".gg:first").clone(true));
              	var in_rulename=$('#rulename').val();
				var in_ruleprice=$('#ruleprice').val();
				var in_goodstock=$('#goodstock').val();
				
				$tr=$("<tr></tr>");
				
				$name_td=$("<td></td>");
				$name_td.text(in_rulename);//"<td>名字</td>"
				$email_td=$("<td></td>");
				$email_td.text(in_ruleprice);//"<td>电邮</td>"
				$tel_td=$("<td></td>");
				$tel_td.text(in_goodstock);//"<td>电话</td>"
				
				$a_td=$("<td></td>");
				$myHref=$("<a></a>");
				$myHref.text("删除");
				$myHref.attr("href","#");
				$a_td.append($myHref);
				
				$tr.append($name_td);
				$tr.append($email_td);
				$tr.append($tel_td);
				$tr.append($a_td);
				
				$myHref.click(function(){
					//如何显示用户名字，并且让用户选择是否真的删除用户
					//<a href='delEmpController.php?name=顺平'>删除</a>
					var b=window.confirm("你确定要删除？"+$(this).parent().parent().children().eq(0).text());
					
					if(b){
						$(this).parent().parent().remove();
						return false;
					}else{
						return false;
					}
				
				})
				
				$('#ruletable tbody').append($tr);
				
	});


	$("body").on('click',".picboxs_action a.delbtn",function(){
		$(this).parents(".piclist").remove();
	})

})

</script> 
<script src="/shop/Public/js/portamento.js"></script> 


</div>
</block>
